<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script type="text/javascript">
        //arguments.callee 返回当前的函数
        function test(){
            console.log(arguments.callee);
        }
        test();
        // 累加
        function sum(n) {
            if (n <= 1) {
                return 1;
            }
            return n + sum(n - 1);
        }
        console.log(sum(100));;
        // 自执行函数累加 使用arguments.callee调佣自执行的匿名函数函数
        let res = (function (n) {
            if (n <= 1) {
                return 1;
            }
            return n + arguments.callee(n - 1);
        })(100);
        console.log(res);
    </script>
</body>

</html>